#include "Event.h"

SK

Event::Event (bool initialState)
: delHan (true)
{
    han = CreateEvent (NULL, TRUE, (BOOL)initialState, NULL);
}

Event::Event (HANDLE han)
: delHan (true), han(han)
{
}

Event::~Event ()
{
    if (han)
        CloseHandle (han);
}


void Event::signal (void)
{
    SetEvent (this->han);
}

void Event::reset (void)
{
    ResetEvent (this->han);
}

bool Event::waitFor (void)
{
    DWORD ret = WaitForSingleObject (this->han, INFINITE);
    return ret == WAIT_OBJECT_0;
}

bool Event::waitFor (u32 timeout)
{
    DWORD ret = WaitForSingleObject (this->han, (DWORD)timeout);
    return ret == WAIT_OBJECT_0;
}

EK